import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

//首页  分类 购物车  个人中心
const MainIndex = resolve => require(['@/components/MainIndex/MainIndex'],resolve);
const HomePage = resolve => require(['@/components/MainIndex/homePage'],resolve);
const MenuPage = resolve => require(['@/components/MainIndex/menuPage'],resolve);
const UserPage = resolve => require(['@/components/MainIndex/userPage'],resolve);
const CartPage = resolve => require(['@/components/MainIndex/cartPage'],resolve);

const searchPage = resolve => require(['@/components/MainIndex/searchPage'],resolve);  //搜索页

//商品页
const ProductList = resolve => require(['@/components/product/productList'],resolve);
const productDetail = resolve => require(['@/components/product/productDetail'],resolve);
const  routerMaps=[
  { name: 'MainIndex',path: '/MainIndex',component: MainIndex,children:[
    {name:'HomePage',path:'/HomePage',component:HomePage},
    {name:'MenuPage',path:'/MenuPage',component:MenuPage},
    {name:'CartPage',path:'/CartPage',component:CartPage},
    {name:'UserPage',path:'/UserPage',component:UserPage}
  ]},
  {name:'searchPage',path:'/searchPage',component:searchPage},
  {name:'ProductList',path:'/ProductList',component:ProductList},
  {name:'productDetail',path:'/productDetail',component:productDetail},
  {path: '*', redirect: '/HomePage'}
];


const router=new Router({
  mode:'hash',
	routes:routerMaps
});


export default router
